Binding SQL parameters with SQL parameters container object
https://gyazo.com/f2458460d144fd444ac74cc6a359f1ff
Example
Table schema
We assume the follwing customer table in example.
code:sql
CREATE TABLE customer (id INT PRIMARY KEY, name VARCHAR)
code:java
// Table name candidates are "CUSTOMER" and "CUSTOMERS"
public class Customer{
public int id;
public String name;
}
code:java
Customer customer = new Customer(99, "Alice");
// inserts a customer object (Customer class is mapped to the table customer automatically)
sorm.insert(customer);
// convert internally
sorm.executeUpdate("INSERT INTO customer (id, name) VALUES (?,?)", 99, "Alice");
// convert internally
PreparedStatement stmt = new PreparedStatement("INSERT INTO customer (id, name) VALUES (?,?)");
stmt.setInt(1, 99);
stmt.setString(2, "Alice");
code:java
// Insert target is indicate explicitly
sorm.insertOn("another_customer_table", customer);
sorm.deleteOn("another_customer_table", customer);